package mrpheu.demo.server.implement;

import java.util.Map;

import mrpheu.demo.server.bean.MessageItem;
import mrpheu.demo.server.interfaces.IMessageStrategy;
import mrpheu.demo.server.interfaces.IZoneClient;


public class MessageStrategyPeer implements IMessageStrategy {
    private MessageItem messageItem;
    Map<Integer, IZoneClient> clientList;
    
    public MessageStrategyPeer(Map<Integer, IZoneClient> clientList, MessageItem messageItem) {
        this.clientList = clientList;
        this.messageItem = messageItem;
    }
    
    @Override
    public void process() {
        System.out.println("Peer active");
        int distinctId = messageItem.getDistinctClient();
        IZoneClient messageClient = this.clientList.get(distinctId);
        messageClient.update(messageItem);
    }

}
